<!DOCTYPE html>
<!--
  Original Project, HTML5 Rocks 'Slides Template' Copyright 2010 Google Inc.
 
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
 
     http://www.apache.org/licenses/LICENSE-2.0
 
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
 
  Original slides: Marcin Wichary (mwichary@google.com)
  Modifications: Ernest Delgado (ernestd@google.com)
                 Alex Russell (slightlyoff@chromium.org)
                 Brad Neuberg

  Keydown generates an HTML5 Rocks-style presentation from a Markdown file, adding
  the ability to full screen backgrounds, CSS overrides, and additional JavaScript.

  Keydown (http://infews.github.com/keydown), Copyright 2010 Infews LLC
-->
<html manifest="cache.manifest">
<head>
  <!--[if gte IE 9]>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <![endif]-->

  <!--[if lt IE 9]>
  <meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1"/>
  <![endif]-->

  <meta charset="utf-8"/>
  <title>r-dev-lessons</title>
  <link href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans+Mono|Permanent+Marker|Lobster|Ruslan+Display" rel="stylesheet" type="text/css"/>

  <!--
    Original HTML5 Rocks CSS extracted for readability
  -->
  <link href="css/rocks.css" rel="stylesheet" type="text/css"/>

  <!--
    Keydown provided CSS & your custom CSS
  -->
  
    <link href="css/keydown.css" rel="stylesheet" type="text/css"/>
  
    <link href="css/syntax_highlighting.css" rel="stylesheet" type="text/css"/>
  
    <link href="css/custom.css" rel="stylesheet" type="text/css"/>
  
    <link href="css/r-dev-lessons.css" rel="stylesheet" type="text/css"/>
  

</head>
<body>
<div class="presentation">
  <div id="presentation-counter"></div>
  <div class="slides">
    <!--
      First slide has Title, Instructions & options. Remove (or display:none) this slide if you like
    -->
    <div class="slide">
      <section class="middle">
        <h1>r-dev-lessons</h1>

        <p>
          Press <span class="key"><b>&rarr;</b></span>, scroll, or swipe to advance
        </p>

        <h3>
          Options
        </h3>
        <ul>
          <li>
            <input type="checkbox" id="toggle-size"/>
            <label for="toggle-size">
              <span>Grow</span>
            </label>
          </li>
          <li>
            <input type="checkbox" id="toggle-transitions" checked/>
            <label for="toggle-transitions">
              <span>Transitions</span>
            </label>
          </li>
          <li>
            <input type="checkbox" id="toggle-gradients" checked/>
            <label for="toggle-gradients">
              <span>Gradients</span>
            </label>
          </li>
          <li>
            <input type="checkbox" id="toggle-counter" checked/>
            <label for="toggle-counter">
              <span>Slide numbers</span>
            </label>
          </li>
        </ul>
        <p>
          Made with <a href="http://infews.github.com/keydown"><b>Keydown</b></a>
        </p>
        <p>
          <a href="http://www.w3.org/html/logo/">
            <img src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-graphics-semantics.png" width="197" height="64" alt="HTML5 Powered with CSS3 / Styling, Graphics, 3D &amp; Effects, and Semantics" title="HTML5 Powered with CSS3 / Styling, Graphics, 3D &amp; Effects, and Semantics">
          </a>
        </p>
      </section>
    </div>
    
      <div class="slide">
  <section class="middle">
    <h1>Lessons Learned in Developing R Packages</h1>

<hr />

<p><img src="images/sleepy.png" width=350 /></p>

<h2><a href="http://yihui.name">Yihui Xie</a></h2>

<p>Department of Statistics, Iowa State University<br/>
Computational Statistics working group</p>

<p>Nov 2, 2011 (i.e. 20111102)</p>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background scattered-leaves">
  <section class="dark middle">
    <h1>Outline</h1>

<p>Nothing here; move on!</p>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="middle">
    <h1>Do we have to suffer from software?</h1>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background terminal">
  <section class="dark middle">
    <h1>How difficult is it to use the Linux servers in our department?</h1>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="middle">
    <h1>Why not RStudio?</h1>

<p>say goodbye to the command <code>nohup</code> since we can use the web interface</p>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background rstudio-web">
  <section>
    

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background steve-jobs">
  <section class="dark middle">
    <h1>On Design</h1>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background bicycle-route">
  <section class="dark middle">
    <h1>Humanity?</h1>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background error-message">
  <section>
    <h1>What Should I Say...</h1>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="middle">
    <h1>Q: How to Make Developers Happier?</h1>

<h2>A: You do not have to buy me beer, but please just do not let me see you use an R version released 2 years ago</h2>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section>
    <h1>animation: Start with Naive Ideas</h1>

<p>the best time to write a package was 5 years ago, and...</p>

<div class="CodeRay">
  <div class="code"><pre>  <span class="c">## rotate the word 'Animation'</span>
  <span class="r">for</span> (i <span class="r">in</span> <span class="i">1</span>:<span class="i">360</span>) {
    plot(<span class="i">1</span>, ann = <span class="co">FALSE</span>, type = <span class="s"><span class="dl">&quot;</span><span class="k">n</span><span class="dl">&quot;</span></span>, axes = <span class="co">FALSE</span>)
    text(<span class="i">1</span>, <span class="i">1</span>, <span class="s"><span class="dl">&quot;</span><span class="k">Animation</span><span class="dl">&quot;</span></span>, 
      srt = i, col = rainbow(<span class="i">360</span>)[i], cex = <span class="i">7</span> * i/<span class="i">360</span>)
    <span class="co">Sys</span>.sleep(<span class="fl">0.01</span>)
  } </pre></div>
</div>




<p align="center"><img src="images/animation-rotation.gif" width=300 /></p>




  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section>
    <h1>animation: Demos and Examples</h1>

<p>do not expect beginners to read source code, and do not expect experts to read documentation, either!</p>

<div class="CodeRay">
  <div class="code"><pre>  library(animation)
  demo(<span class="s"><span class="dl">'</span><span class="k">fire</span><span class="dl">'</span></span>)  <span class="c"># an application of image()</span></pre></div>
</div>




<p align="center"><img src="images/fire.gif" /></p>




  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>animation: Demos and Examples (cont'd)</h1>

<p>examples are fast guides to usage</p>

<div class="CodeRay">
  <div class="code"><pre>  library(animation)
  <span class="i">?a</span>nimation
  <span class="c">## this gives you an overview of the package</span></pre></div>
</div>


<ul>
<li>images are supported in documentation in R 2.14 (use <code>\figure{}</code>)</li>
<li>should be possible to create figures dynamically with Sweave in future</li>
<li>honestly, I do not like the old style of R documentation at all</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>animation: Interfaces</h1>

<ul>
<li>why <code>ani.start()</code> and <code>ani.stop()</code> became <code>saveHTML()</code></li>
<li>use modern CSS elements (round corners and shadow, etc) rather than the old clunky styles</li>
<li>make it appealing enough that the user cannot wait clicking the button!</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background interface-old">
  <section>
    

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background interface-new">
  <section>
    

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="middle">
    <h1>animation: Automatic Configurations</h1>

<p><img src="images/automatic.gif" alt="automatic" /></p>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>animation: Automatic Configurations (cont'd)</h1>

<ul>
<li><code>saveGIF()</code> uses ImageMagick or GraphicsMagick to convert images to GIF animations; need to know where they are installed</li>
<li>automatically search for ImageMagick in Windows Registry Hive using <code>readRegistry()</code> (very likely to succeed)</li>
<li>instead of teaching what is the environmental variable <code>PATH</code> (very frustrating thanks to &ldquo;the system that is just <em>this</em> tall&rdquo;)</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>animation: What Do I Regret Today?</h1>

<ul>
<li>function names: now I'm more in favor of <code>foo_bar</code> than <code>foo.bar</code> (why? S3 generic functions) or <code>fooBar</code> (why? <code>_</code> is a clearer separator than capital letters)</li>
<li>built a Wiki site too early and it is too big to maintain (<a href="http://animation.yihui.name">http://animation.yihui.name</a>); I should have used tools like Sweave to build it dynamically (my new package <a href="http://yihui.github.com/knitr"><strong>knitr</strong></a> was partly motivated from here)</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>formatR: Computing on the Code</h1>

<ul>
<li>R can compute on its own code: <code>parse()</code> and <code>deparse()</code></li>
<li>the <a href="http://github.com/yihui/formatR/wiki"><strong>formatR</strong></a> package uses the side effect of them to reformat R code</li>
<li>you give me <code>1+1</code> and I return you <code>1 + 1</code> (what the heck is the difference?)</li>
</ul>


<p>well, compare</p>

<div class="CodeRay">
  <div class="code"><pre><span class="r">for</span>(k <span class="r">in</span> <span class="i">1</span>:<span class="i">10</span>){j=cos(sin(k)*k^<span class="i">2</span>)+<span class="i">3</span>;print(j-<span class="i">5</span>)}</pre></div>
</div>


<p>to</p>

<div class="CodeRay">
  <div class="code"><pre><span class="r">for</span> (k <span class="r">in</span> <span class="i">1</span>:<span class="i">10</span>) {
    j = cos(sin(k) * k^<span class="i">2</span>) + <span class="i">3</span>
    print(j - <span class="i">5</span>)
} </pre></div>
</div>




  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>formatR: Motivation</h1>

<ul>
<li>it is not the fault of people to create &ldquo;long chunks of ill-formatted R code piled beside the Snedecor-Grad-Copier printer&rdquo;</li>
<li>why cannot a workman blame his tools?</li>
<li>Stat579 students motivated the <code>tidy.eval()</code> function</li>
</ul>


<p>I frown on this in homeworks (score: 99.5):</p>

<div class="CodeRay">
  <div class="code"><pre>&gt; <span class="i">1</span>+<span class="i">1</span>
[<span class="i">1</span>] <span class="i">2</span></pre></div>
</div>


<p><code>tidy.eval()</code> does this (score: 100):</p>

<div class="CodeRay">
  <div class="code"><pre><span class="i">1</span> + <span class="i">1</span>
<span class="c">## [1] 2</span></pre></div>
</div>




  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background inferno">
  <section class="middle dark">
    <h1>Rd2roxygen: Escaping the Rd Inferno</h1>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>Rd2roxygen: How I Regained Enthusiasm from roxygen</h1>

<ul>
<li>I was once extremely frustrated at maintaining the animation package due to documentation</li>
<li>idea of roxygen: source code and documentation are in the same file</li>
</ul>


<div class="CodeRay">
  <div class="code"><pre><span class="c">##' This is title</span>
<span class="c">##' @param a documentation for argument a</span>
<span class="c">##' @param b documentation for argument b</span>
f = function(a, b) {
    ...
}</pre></div>
</div>


<ul>
<li>no longer needs to switch back and forth between <code>R/f.R</code> and <code>man/f.Rd</code></li>
<li>documentation is generated dynamically</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>Rd2roxygen: How to Escape the Inferno</h1>

<ul>
<li>roxygen translates comments to Rd</li>
<li>Rd2roxygen translates Rd back to roxygen comments, e.g.</li>
</ul>


<p>from</p>

<div class="CodeRay">
  <div class="code"><pre>\arguments{
  \item{a}{documentation for argument a}
}</pre></div>
</div>


<p>to</p>

<div class="CodeRay">
  <div class="code"><pre><span class="c">##' @param a documentation for argument a</span></pre></div>
</div>


<ul>
<li>you maintain a <em>single</em> source from now on</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background grim-repo">
  <section class="dark">
    <h1>GitHub: One Command to Fork em All</h1>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background poptocat">
  <section>
    

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background bear-cavalry">
  <section>
    

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>Why Version Control?</h1>

<ul>
<li>keep track of what you have been doing (accumulatively)</li>
<li>a proof of hard work to your advisor</li>
<li>save tears when your system crashes</li>
<li>much much easier <a href="https://github.com/hadley/evaluate/pull/9">collaboration</a> with others</li>
<li>...</li>
<li>why GitHub? community, easy collaboration, ... (compare to R-Forge)</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>Why do I use <code>=</code> instead of <code>&lt;-</code>?</h1>

<ul>
<li>it is simpler to type (although Emacs/ESS binds <code>&lt;-</code> to <code>_</code>)</li>
<li>almost all other languages use <code>=</code></li>
<li>it does <em>not</em> confuse me at all (main reason why some people are against recommend <code>=</code>)</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>Names: Important!</h1>

<ul>
<li>can you remember the name <code>CvM2SL2Test</code> or <code>HumMeth27QCReport</code></li>
<li>if people cannot even remember your name, how are you supposed to be famous/popular?</li>
<li>Hadley's principle: Google-able</li>
<li>an unbeatable name: lubridate</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="bulleted">
    <h1>Have Fun</h1>

<ul>
<li>the <a href="http://cran.r-project.org/package=fun">fun</a> package: games and fun</li>
<li>animation: started from fun</li>
<li>cranvas: <a href="http://vimeo.com/30173477">interactive graphics</a> is fun</li>
<li>knitr (an alternative to Sweave): dynamic report is fun</li>
<li>...</li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide">
  <section class="middle">
    

<object width="600" height="619"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=30173477&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=30173477&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="619"></embed></object>




  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background dragon">
  <section class="dark middle">
    <h1>Aim at Problems, Instead of Killing the Dragon</h1>

<p>朱泙漫学屠龙于支离益，单千金之家，三年技成而无所用其巧。</p>

<p>《庄子·列御寇》</p>

  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
      <div class="slide full-background constructocat">
  <section>
    <h1>Thanks!</h1>

<ul>
<li><a href="https://github.com/yihui">https://github.com/yihui</a></li>
</ul>


  </section>
  <div class="attribution hidden">
    <a href="">
      
    </a>
  </div>
</div>

    
  </div>
</div>

<!--
  Original HTML5 Rocks JavaScript extracted for readability
-->
<script src="js/rocks.js" type="text/javascript"></script>

<!--[if lt IE 9]>
<script src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<script>CFInstall.check({ mode: "overlay" });</script>
<![endif]-->

<!--
  Keydown puts your custom JS here
-->

  <script src="js/custom.js" type="text/javascript"></script>


</body>
</html>